From: Tim Starling Date: Wed, 11 Jan 2006 02:19:41 +0000 (+0000) Subject: If a template is a redirect, register both titles in the templatelinks table. This... X-Git-Tag: 1.6.0~614 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=ba248c867df80deee100e369d5265df63bbdb0b6;p=lhc%2Fweb%2Fwiklou.git If a template is a redirect, register both titles in the templatelinks table. This ensures that the cache will be invalidated. --- diff --git a/includes/Parser.php b/includes/Parser.php index 8a301b41f5..0030dacda1 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2514,15 +2514,12 @@ class Parser $this->disableCache(); } } else { - $article = new Article( $title ); - $articleContent = $article->fetchContent(0, false); + $articleContent = $this->fetchTemplate( $title ); if ( $articleContent !== false ) { $found = true; $text = $articleContent; $replaceHeadings = true; } - # Register a template reference whether or not the template exists - $this->mOutput->addTemplate( $title, $article->getID() ); } } @@ -2645,6 +2642,28 @@ class Parser } } + /** + * Fetch the unparsed text of a template and register a reference to it. + */ + function fetchTemplate( $title ) { + $text = false; + // Loop to fetch the article, with up to 1 redirect + for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) { + $rev = Revision::newFromTitle( $title ); + $this->mOutput->addTemplate( $title, $title->getArticleID() ); + if ( !$rev ) { + break; + } + $text = $rev->getText(); + if ( $text === false ) { + break; + } + // Redirect? + $title = Title::newFromRedirect( $text ); + } + return $text; + } + /** * Translude an interwiki link. */